package com.pinganfu.tesla.iwallet;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.pinganfu.tesla.iwallet.session.SessionManager;
import com.pinganfu.tesla.iwallet.util.TeslaUtil;
import compinganfu.tesla.iwallet.widget.EditTextWithDel;

public class OtherLoginActivity extends Activity implements OnClickListener {

	private EditTextWithDel txtAccount = null;
	private EditTextWithDel txtLoginPwd = null;
	private Button btnLogin = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_other_login);

		txtAccount = (EditTextWithDel) findViewById(R.id.txt_account);
		txtLoginPwd = (EditTextWithDel) findViewById(R.id.txt_login_pwd);
		txtLoginPwd.setActionButton(btnLogin);

		SessionManager sm = SessionManager.getInstance();
		if (sm.getUserPref() == null) {
			txtAccount.setText(sm.getMobileNo());
		} else {
			txtAccount.setText(sm.getUserPref().getMobileNo());
		}

		btnLogin = (Button) findViewById(R.id.btn_login);
		btnLogin.setOnClickListener(this);

		((TextView) findViewById(R.id.tv_forget_pwd)).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				TeslaUtil.gotoActivity(OtherLoginActivity.this, ForgetPwdActivity.class);
			}
		});
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {
			case R.id.btn_login :
				TeslaUtil.gotoActivity(this, MainActivity.class);
				finish();
				break;
		}
	}
}
